<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>
<%@taglib uri="/WEB-INF/life.tld" prefix="life"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="jxInclude.jsp"%>
<%@include file="jsInclude.jsp"%>
<%@include file="cssInclude.jsp"%>
<style>
.gridBox {
  float:left;
  display: block;
  position: relative;
  margin: 0px 10px;
  border: 1px solid #ccc;
  width: 774px;
  height: 300px;
  clear: both;
}
</style>
<SCRIPT type="text/javascript">
var callURL = "<%=request.getContextPath()%>/articleIndex.do?action=list";
var _rootCls;
var artType_ ;
var pageC = 0;
var artData = new Array();
var grid ;
var MyModel ;

var d1;
window.addEvent('load', function(){
	_rootCls  = $("rootClsInfo").value.split(":")[1];
	artType_ = $("artType").value;
	MyModel = new Class({
		Extends:Jx.Grid.Model,
		myWidths:[60,215,100,120,60,60,60,60],
		getColumnWidth:function(col){return this.myWidths[col]}
	});

	grid = new Jx.Grid({
	      alternateRowColors: false,
	      rowHeaders: true,
	      columnHeaders: true,
	      rowPrelight: false,
	      columnPrelight: false,
	      rowHeaderPrelight: false,
	      columnHeaderPrelight: false,
	      cellPrelight: false,
	      rowSelection: false,
	      columnSelection: false,
	      cellSelection: false
	    }).addTo('gridArea');
	getList();
	initBtn();
});

function in_init(data){
	var colHeaders = ['选择','标题','作者','更新时间','热门','置顶','推荐','有效'];
	var myModelIn = new MyModel(data,{
		columnHeaders:colHeaders,
		rowHeaderWidth:20
	});
	grid.setModel(myModelIn);
	grid.options.rowPrelight = true;
	grid.options.rowSelection = true;
}
function getList(){
	var xhConn = new XHConn();
	xhConn.connect(callURL,"POST","&rootCls="+_rootCls+"&first=0&artType="+artType_,function(xh){
			var res = eval('('+xh.responseText+')');
			if(res){
				if("1" == res.result){//成功
					pageC = res.page;//页数
					artData = res.msg;
					in_init(artData);
				}else{
					var d2 = new Jx.Dialog({
						lable:'提示信息',
						modal:false,
						resize:false,
						move:false,
						content:'请求出现错误'+res.msg
					});
				}
			}else{
				var d1 = new Jx.Dialog({
					label:'提示信息',
					modal:true,
					resize:false,
					move:false,
					content:'请求失败!'
				});
				d1.open.bind(d1);
			}
		});
}
var addArtBtn,delArtBtn,editArtBtn,topArtBtn,commendArtBtn,hotArtBtn,upPageBtn,downPageBtn;

function initBtn(){
	d1 = new Jx.Dialog({
		label: '编辑文章',
        image: '<%=request.getContextPath()%>/images/page_white_code.png',
        modal: true, 
        resize: true,
        width:600,
        height:400,
        horizontal: '200 left',
        vertical:'50 top',
        contentURL: ""
	});
	addArtBtn = new Jx.Button({
		id:'addBtnJx',
		label:'添加',
		onClick:function(){addArt();}
	});
	addArtBtn.addTo("addArtBtn");
	delArtBtn = new Jx.Button({
		id:'delBtnJx',
		label:'删除',
		onClick:function(){delArt();}
	});
	delArtBtn.addTo('delArtBtn');
	editArtBtn = new Jx.Button({
		id:'editBtnJx',
		label:'编辑',
		onClick:function(){editArt();}
	});
	editArtBtn.addTo("editArtBtn");
	topArtBtn = new Jx.Button({
		id:'topBtnJx',
		label:'置顶',
		onClick:function(){topArt();}
	});
	topArtBtn.addTo('topArtBtn');
	commendArtBtn = new Jx.Button({
		id:'commendArtJx',
		label:'推荐',
		onClick:function(){commendArt();}
	});
	commendArtBtn.addTo('commendArtBtn');
	hotArtBtn = new Jx.Button({
		id:'hotArtJx',
		label:'热门',
		onClick:function(){hotArt();}
	});
	hotArtBtn.addTo('hotArtBtn');

	upPageBtn = new Jx.Button({
		id:'upPageJx',
		label:'上一页',
		onClick:function(){upPage();}
	});
	upPageBtn.addTo("upPageBtn");
	downPageBtn = new Jx.Button({
		id:'downPageJx',
		label:'下一页',
		onClick:function(){downPage();}
	});
	downPageBtn.addTo('downPageBtn');

	
}

function addArt(){
	var r_clsInfo = $("rootClsInfo").value;
	var _clsCode = r_clsInfo.split(":")[1];
	var addUrl ="<%=request.getContextPath()%>/articleAct.do?call=addUI&clsCode="+_clsCode;
	window.location.href=addUrl;
	//d1.open.bind(d1);
	//d1.show();
	
}
function delArt(){}
function editArt(){}
function topArt(){}
function commendArt(){}
function hotArt(){}
function upPage(){}
function downPage(){}
function gotoPage(){}
</SCRIPT>
<BODY style="text-algin:left;">
	<div style="width:775px;float:left;">
		<div id="gridArea" class="gridBox"></div>
		<input type="hidden" id="rootClsInfo" name="rootClsInfo" value='<s:property value="%{rootClsInfo}"/>'/>
		<input type="hidden" id="artType" name="artType" value='<s:property value="%{artType}"/>'>
	</div>
	<!-- 控制按钮部分 -->
	<div style="float:left;width:800px;margin-top:5px;">
		<div style="float:left;padding-left:5px;width:300px;">
			<div id="addArtBtn"></div>
			<div id="delArtBtn"></div>
			<div id="editArtBtn"></div>
			<div id="topArtBtn"></div>
			<div id="hotArtBtn"></div>
			<div id="commendArtBtn"></div>&nbsp;
		</div>
		<div style="float:right;padding-right:5px;width:370px;">
			<div id="upPageBtn"></div>
			<div id="downPageBtn"></div>
			<div id="gotoPageD"></div>
		</div>
	</div>
</BODY>
</HTML>